package com.sixth.service.impl;

import com.sixth.annotation.PageInfoAdvice;
import com.sixth.bean.MarketFootprintExample;
import com.sixth.bean.common.BasePageInfo;
import com.sixth.mapper.MarketFootprintMapper;
import com.sixth.service.AdminFootprintService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;



/**
 * @ClassName AdminFootprintServiceImpl
 * @Description TODO
 * @Author XiaoWJ
 * @Date 2022/9/7 19:58
 **/
@Service
public class AdminFootprintServiceImpl implements AdminFootprintService {

    @Autowired
    MarketFootprintMapper marketFootprintMapper;


    @PageInfoAdvice
    @Override
    public Object list(BasePageInfo basePageInfo, Integer userId, Integer goodsId) {

        MarketFootprintExample example = new MarketFootprintExample();

        MarketFootprintExample.Criteria criteria = example.createCriteria();
        if (userId != null) {
            criteria.andUserIdEqualTo(userId);
        }

        if (goodsId != null) {
            criteria.andGoodsIdEqualTo(goodsId);

        }

        example.setOrderByClause(basePageInfo.getSort() + " " + basePageInfo.getOrder());
        Object marketFootprints = marketFootprintMapper.selectByExample(example);
        return marketFootprints;
    }
}
